"""
客户端
"""
from socket import *
import sys


class Handle:
    def __init__(self):
        self.address = ("127.0.0.1",8889)
        self.sock = self.connect_server()

    def connect_server(self):
        sock = socket()
        sock.connect(self.address)
        return sock


    def do_sign(self):
        self.sock.send(b"test")


    def select_word(self):
        pass

    def do_quit(self):
        self.sock.send(b"E")
        self.sock.close()
        sys.exit("谢谢使用")

class DictView:
    def __init__(self):
        self.handle = Handle()

    def menu_1(self):
        while True:
            print("""
        ========登录界面=======
        1.注册  2.登录  3.退出
        ======================
        """)
            item = input("请输入选项：")
            if item == "1":
                self.menu_2()
                self.handle.do_sign()
            elif item == "2":
                pass
            elif item == "3":
                self.handle.do_quit()
                break
            else:
                print("请重新输入选项")

    def menu_2(self):
        while True:
            print("""
        ==========登录界面========
        1.查单词  2.历史记录  3.注销
        =========================
        """)
            item = input("请输入选项：")
            if item == "1":
                self.handle.select_word()
            elif item == "2":
                pass
            elif item == "3":
                break
            else:
                print("请重新输入选项")

    def main(self):
        while True:
            self.menu_1()


if __name__ == '__main__':
    dict = DictView()
    dict.main()